<html>
<head><meta charset="utf-8"><title>Simd Shuffles · project-portable-simd · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/index.html">project-portable-simd</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html">Simd Shuffles</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="224978828"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/224978828" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#224978828">(Feb 03 2021 at 06:33)</a>:</h4>
<p>I can't believe this monstrosity compiles.<br>
<a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=b1bbc71a0c61234d977475dfa88de73d">https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=b1bbc71a0c61234d977475dfa88de73d</a></p>



<a name="224978896"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/224978896" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#224978896">(Feb 03 2021 at 06:34)</a>:</h4>
<p><span aria-label="grimacing" class="emoji emoji-1f62c" role="img" title="grimacing">:grimacing:</span></p>



<a name="224978986"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/224978986" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#224978986">(Feb 03 2021 at 06:36)</a>:</h4>
<p>...anyways... I have been poking at SIMD shuffles all night. Const generics aren't entirely there yet for a "straight" <code>pub const fn shuffle&lt;const M: usize, const Idx: [usize; M]&gt;(self, other: Self) -&gt; Self&lt;M&gt;</code> signature yet, I think.</p>



<a name="224979036"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/224979036" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#224979036">(Feb 03 2021 at 06:37)</a>:</h4>
<p>this is because</p>
<div class="codehilite"><pre><span></span><code>error[E0770]: the type of const parameters must not depend on other generic parameters
  --&gt; crates/core_simd/src/macros.rs:84:69
   |
84 |             pub const fn shuffle&lt;const M: usize, const Idx: [usize; M]&gt;(self, other: Self) -&gt; Self {
   |                                                                     ^ the type must not depend on the parameter `M`
</code></pre></div>



<a name="224979114"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/224979114" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#224979114">(Feb 03 2021 at 06:39)</a>:</h4>
<p>What about if we took an entirely different approach</p>



<a name="224979143"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/224979143" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#224979143">(Feb 03 2021 at 06:39)</a>:</h4>
<p>What if we exposed a ShuffleIndex trait that's implemented for all arrays of usize</p>



<a name="224979206"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/224979206" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#224979206">(Feb 03 2021 at 06:40)</a>:</h4>
<p>I have been thinking about that!</p>



<a name="224979211"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/224979211" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#224979211">(Feb 03 2021 at 06:40)</a>:</h4>
<p>Oh nice</p>



<a name="224979224"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/224979224" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#224979224">(Feb 03 2021 at 06:40)</a>:</h4>
<p>I know traits aren't supported in const fn yet either, but there may be an unstable feature for it</p>



<a name="224979396"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/224979396" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#224979396">(Feb 03 2021 at 06:43)</a>:</h4>
<p>Actually you may still end up with the same error. I think the const parameter would still end up depending on another generic parameter</p>



<a name="224979589"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/224979589" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#224979589">(Feb 03 2021 at 06:46)</a>:</h4>
<p>Is there a reason for the shuffle index length to be different than the size of the vector?</p>



<a name="224980516"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/224980516" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#224980516">(Feb 03 2021 at 07:01)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="n">error</span><span class="p">[</span><span class="n">E0770</span><span class="p">]</span>: <span class="nc">the</span><span class="w"> </span><span class="k">type</span> <span class="nc">of</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="n">parameters</span><span class="w"> </span><span class="n">must</span><span class="w"> </span><span class="n">not</span><span class="w"> </span><span class="n">depend</span><span class="w"> </span><span class="n">on</span><span class="w"> </span><span class="n">other</span><span class="w"> </span><span class="n">generic</span><span class="w"> </span><span class="n">parameters</span><span class="w"></span>
<span class="w">  </span><span class="o">-</span>-&gt; <span class="nc">crates</span><span class="o">/</span><span class="n">core_simd</span><span class="o">/</span><span class="n">src</span><span class="o">/</span><span class="n">macros</span><span class="p">.</span><span class="n">rs</span>:<span class="mi">85</span>:<span class="mi">45</span><span class="w"></span>
<span class="w">   </span><span class="o">|</span><span class="w"></span>
<span class="mi">85</span><span class="w"> </span><span class="o">|</span><span class="w">             </span><span class="k">pub</span><span class="w"> </span><span class="k">fn</span> <span class="nf">shuffle</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">I</span>: <span class="p">[</span><span class="kt">usize</span><span class="p">;</span><span class="w"> </span><span class="n">LANES</span><span class="p">]</span><span class="o">&gt;</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">other</span>: <span class="nc">Self</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">Self</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">   </span><span class="o">|</span><span class="w">                                             </span><span class="o">^^^^^</span><span class="w"> </span><span class="n">the</span><span class="w"> </span><span class="k">type</span> <span class="nc">must</span><span class="w"> </span><span class="n">not</span><span class="w"> </span><span class="n">depend</span><span class="w"> </span><span class="n">on</span><span class="w"> </span><span class="n">the</span><span class="w"> </span><span class="n">parameter</span><span class="w"> </span><span class="err">`</span><span class="n">LANES</span><span class="err">`</span><span class="w"></span>
</code></pre></div>
<p>Are you trying to squirm out that way? :^)<br>
I already checked, that gate is sealed shut.</p>



<a name="224980576"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/224980576" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#224980576">(Feb 03 2021 at 07:02)</a>:</h4>
<p>Yeah I guess that's still a generic parameter</p>



<a name="224980693"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/224980693" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#224980693">(Feb 03 2021 at 07:04)</a>:</h4>
<p>Worst case we can still go the const argument route <span aria-label="shrug" class="emoji emoji-1f937" role="img" title="shrug">:shrug:</span>‍♂️</p>



<a name="224980803"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/224980803" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#224980803">(Feb 03 2021 at 07:06)</a>:</h4>
<p>What happens if you add an associated constant equal to the number of lanes? And use that</p>



<a name="224983030"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/224983030" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#224983030">(Feb 03 2021 at 07:43)</a>:</h4>
<p>realistically, the bigger issue is that the intrinsics in Rust are <code>simd_shuffle{N}</code> where N is a number that is actually part of the function name. :D</p>



<a name="224983631"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/224983631" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#224983631">(Feb 03 2021 at 07:53)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="w">            </span><span class="sd">/// const fn shuffle</span>
<span class="w">            </span><span class="cp">#[inline]</span><span class="w"></span>
<span class="w">            </span><span class="k">pub</span><span class="w"> </span><span class="k">fn</span> <span class="nf">shuffle2</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">W</span>: <span class="kt">u32</span><span class="p">,</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="n">X</span>: <span class="kt">u32</span><span class="o">&gt;</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">other</span>: <span class="nc">Self</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="cp">$name</span><span class="o">&lt;</span><span class="mi">2</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                </span><span class="k">unsafe</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="k">crate</span>::<span class="n">intrinsics</span>::<span class="n">simd_shuffle2</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">other</span><span class="p">,</span><span class="w"> </span><span class="p">[</span><span class="n">W</span><span class="p">,</span><span class="w"> </span><span class="n">X</span><span class="p">])</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="w">            </span><span class="p">}</span><span class="w"></span>

<span class="w">            </span><span class="sd">/// const fn shuffle</span>
<span class="w">            </span><span class="cp">#[inline]</span><span class="w"></span>
<span class="w">            </span><span class="k">pub</span><span class="w"> </span><span class="k">fn</span> <span class="nf">shuffle4</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">W</span>: <span class="kt">u32</span><span class="p">,</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="n">X</span>: <span class="kt">u32</span><span class="p">,</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="n">Y</span>: <span class="kt">u32</span><span class="p">,</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="n">Z</span>: <span class="kt">u32</span><span class="o">&gt;</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">other</span>: <span class="nc">Self</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="cp">$name</span><span class="o">&lt;</span><span class="mi">4</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                </span><span class="k">unsafe</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="k">crate</span>::<span class="n">intrinsics</span>::<span class="n">simd_shuffle4</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">other</span><span class="p">,</span><span class="w"> </span><span class="p">[</span><span class="n">W</span><span class="p">,</span><span class="w"> </span><span class="n">X</span><span class="p">,</span><span class="w"> </span><span class="n">Y</span><span class="p">,</span><span class="w"> </span><span class="n">Z</span><span class="p">])</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="w">            </span><span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>so like, this works ofc</p>



<a name="224984763"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/224984763" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#224984763">(Feb 03 2021 at 08:08)</a>:</h4>
<p>..wow I may have found something hilarious.</p>



<a name="224984986"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/224984986" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#224984986">(Feb 03 2021 at 08:12)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="n">error</span><span class="p">[</span><span class="n">E0747</span><span class="p">]</span>: <span class="nc">type</span><span class="w"> </span><span class="n">provided</span><span class="w"> </span><span class="n">when</span><span class="w"> </span><span class="n">a</span><span class="w"> </span><span class="n">constant</span><span class="w"> </span><span class="n">was</span><span class="w"> </span><span class="n">expected</span><span class="w"></span>
<span class="w"> </span><span class="o">-</span>-&gt; <span class="nc">crates</span><span class="o">/</span><span class="n">core_simd</span><span class="o">/</span><span class="n">tests</span><span class="o">/</span><span class="n">permute</span><span class="p">.</span><span class="n">rs</span>:<span class="mi">9</span>:<span class="mi">26</span><span class="w"></span>
<span class="w">  </span><span class="o">|</span><span class="w"></span>
<span class="mi">9</span><span class="w"> </span><span class="o">|</span><span class="w">     </span><span class="kd">let</span><span class="w"> </span><span class="n">c</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">a</span><span class="p">.</span><span class="n">shuffle2</span>::<span class="o">&lt;</span><span class="p">[</span><span class="kt">u32</span><span class="p">;</span><span class="w"> </span><span class="mi">2</span><span class="p">]</span><span class="o">&gt;</span><span class="p">(</span><span class="n">b</span><span class="p">);</span><span class="w"></span>
<span class="w">  </span><span class="o">|</span><span class="w">                          </span><span class="o">^^^^^^^^</span><span class="w"></span>

<span class="n">error</span>: <span class="nc">aborting</span><span class="w"> </span><span class="n">due</span><span class="w"> </span><span class="n">to</span><span class="w"> </span><span class="n">previous</span><span class="w"> </span><span class="n">error</span><span class="w"></span>

<span class="n">For</span><span class="w"> </span><span class="n">more</span><span class="w"> </span><span class="n">information</span><span class="w"> </span><span class="n">about</span><span class="w"> </span><span class="n">this</span><span class="w"> </span><span class="n">error</span><span class="p">,</span><span class="w"> </span><span class="kr">try</span><span class="w"> </span><span class="err">`</span><span class="n">rustc</span><span class="w"> </span><span class="o">--</span><span class="n">explain</span><span class="w"> </span><span class="n">E0747</span><span class="err">`</span><span class="p">.</span><span class="w"></span>
</code></pre></div>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="n">error</span>: <span class="nc">unmatched</span><span class="w"> </span><span class="n">angle</span><span class="w"> </span><span class="n">bracket</span><span class="w"></span>
<span class="w"> </span><span class="o">-</span>-&gt; <span class="nc">crates</span><span class="o">/</span><span class="n">core_simd</span><span class="o">/</span><span class="n">tests</span><span class="o">/</span><span class="n">permute</span><span class="p">.</span><span class="n">rs</span>:<span class="mi">9</span>:<span class="mi">25</span><span class="w"></span>
<span class="w">  </span><span class="o">|</span><span class="w"></span>
<span class="mi">9</span><span class="w"> </span><span class="o">|</span><span class="w">     </span><span class="kd">let</span><span class="w"> </span><span class="n">c</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">a</span><span class="p">.</span><span class="n">shuffle2</span>::<span class="o">&lt;</span><span class="p">[</span><span class="mi">3</span><span class="p">,</span><span class="w"> </span><span class="mi">1</span><span class="p">;</span><span class="w"> </span><span class="mi">2</span><span class="p">]</span><span class="o">&gt;</span><span class="p">(</span><span class="n">b</span><span class="p">);</span><span class="w"></span>
<span class="w">  </span><span class="o">|</span><span class="w">                         </span><span class="o">^</span><span class="w"> </span><span class="n">help</span>: <span class="nc">remove</span><span class="w"> </span><span class="n">extra</span><span class="w"> </span><span class="n">angle</span><span class="w"> </span><span class="n">bracket</span><span class="w"></span>

<span class="n">error</span>: <span class="nc">expected</span><span class="w"> </span><span class="k">type</span><span class="p">,</span><span class="w"> </span><span class="n">found</span><span class="w"> </span><span class="err">`</span><span class="mi">3</span><span class="err">`</span><span class="w"></span>
<span class="w"> </span><span class="o">-</span>-&gt; <span class="nc">crates</span><span class="o">/</span><span class="n">core_simd</span><span class="o">/</span><span class="n">tests</span><span class="o">/</span><span class="n">permute</span><span class="p">.</span><span class="n">rs</span>:<span class="mi">9</span>:<span class="mi">27</span><span class="w"></span>
<span class="w">  </span><span class="o">|</span><span class="w"></span>
<span class="mi">9</span><span class="w"> </span><span class="o">|</span><span class="w">     </span><span class="kd">let</span><span class="w"> </span><span class="n">c</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">a</span><span class="p">.</span><span class="n">shuffle2</span>::<span class="o">&lt;</span><span class="p">[</span><span class="mi">3</span><span class="p">,</span><span class="w"> </span><span class="mi">1</span><span class="p">;</span><span class="w"> </span><span class="mi">2</span><span class="p">]</span><span class="o">&gt;</span><span class="p">(</span><span class="n">b</span><span class="p">);</span><span class="w"></span>
<span class="w">  </span><span class="o">|</span><span class="w">                           </span><span class="o">^</span><span class="w"> </span><span class="n">expected</span><span class="w"> </span><span class="k">type</span>

<span class="nc">error</span>: <span class="nc">aborting</span><span class="w"> </span><span class="n">due</span><span class="w"> </span><span class="n">to</span><span class="w"> </span><span class="mi">2</span><span class="w"> </span><span class="n">previous</span><span class="w"> </span><span class="n">errors</span><span class="w"></span>
</code></pre></div>
<p>Is this as busted as I think it is? <span aria-label="grinning face with smiling eyes" class="emoji emoji-1f601" role="img" title="grinning face with smiling eyes">:grinning_face_with_smiling_eyes:</span></p>



<a name="224986555"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/224986555" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#224986555">(Feb 03 2021 at 08:33)</a>:</h4>
<p>Filed this I guess. rustc go home, you're drunk. <a href="https://github.com/rust-lang/rust/issues/81698">https://github.com/rust-lang/rust/issues/81698</a></p>



<a name="224988576"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/224988576" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#224988576">(Feb 03 2021 at 08:57)</a>:</h4>
<p>And I have mulled it over from a few directions but afaict the problem with using [array].shuffle(v1, v2) -&gt; v3 is that [array] is not guaranteed to be statically known.</p>



<a name="225034226"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225034226" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225034226">(Feb 03 2021 at 15:49)</a>:</h4>
<p>We could always change/improve the intrinsic to not require a number in the name</p>



<a name="225035803"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225035803" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225035803">(Feb 03 2021 at 15:58)</a>:</h4>
<p>we still have to guarantee it type checks tho'.</p>



<a name="225035888"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225035888" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225035888">(Feb 03 2021 at 15:59)</a>:</h4>
<p>Agreed. Still thinking about that one</p>



<a name="225036031"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225036031" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225036031">(Feb 03 2021 at 16:00)</a>:</h4>
<p>strictly speaking, all the information is there and can "obviously" be applied to generate the correct inputs and outputs, so I'm not too worried.</p>



<a name="225036554"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225036554" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225036554">(Feb 03 2021 at 16:02)</a>:</h4>
<p>since what we know is going to be the case is that we have a statically-known array as an input and that the array length will be the length of the output.</p>



<a name="225123400"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225123400" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225123400">(Feb 04 2021 at 06:24)</a>:</h4>
<p>...macro expansion, maybe?</p>



<a name="225124278"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225124278" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225124278">(Feb 04 2021 at 06:40)</a>:</h4>
<p>nope! I'm not good enough yet at least.</p>



<a name="225126509"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225126509" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225126509">(Feb 04 2021 at 07:23)</a>:</h4>
<p>OK, this is what I was able to pull together for an API for SIMD shuffles with the compiler intrinsics and const generics as they currently stand. It is neither pretty nor great, and also suffers from the 64-lane limitation (highly relative "suffers" since that covers most silicon in existence, but servers with SVE are shipping <strong>this</strong> year).<br>
<a href="https://github.com/rust-lang/stdsimd/commit/3e88fb339891d868ce8e12675b87195b4855382a">https://github.com/rust-lang/stdsimd/commit/3e88fb339891d868ce8e12675b87195b4855382a</a></p>



<a name="225127990"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225127990" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225127990">(Feb 04 2021 at 07:45)</a>:</h4>
<p>Hmm. So my only thought, does it even make sense to simultaneously shuffle and shrink vectors?</p>



<a name="225128100"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225128100" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225128100">(Feb 04 2021 at 07:47)</a>:</h4>
<p>Ive definitely never done that before. I think on x86 that's probably a bad thing to do</p>



<a name="225128426"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225128426" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225128426">(Feb 04 2021 at 07:53)</a>:</h4>
<p>NEON's tbl and tbx instructions can compose a new vector from <strong>four</strong> different vectors.<br>
and in general, the way the intrinsic is set up, T and U are separately defined.</p>



<a name="225128521"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225128521" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225128521">(Feb 04 2021 at 07:54)</a>:</h4>
<p>and I couldn't really find a way to smoothly get shuffle working in a "lane dependent" way. I guess I could impl shuffle as shuffle2 for SimdType&lt;2&gt;, is that what you're thinking of?</p>



<a name="225128529"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225128529" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225128529">(Feb 04 2021 at 07:54)</a>:</h4>
<p>Sorry, what I mean is does it make sense to take a 32 lane vector and make a 4 lane vector from it, etc</p>



<a name="225128537"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225128537" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225128537">(Feb 04 2021 at 07:54)</a>:</h4>
<p>Yeah that's what I meant</p>



<a name="225128542"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225128542" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225128542">(Feb 04 2021 at 07:54)</a>:</h4>
<p>hmm.</p>



<a name="225128593"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225128593" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225128593">(Feb 04 2021 at 07:55)</a>:</h4>
<p>I suppose it may be useful somewhere to someone, especially if you're using vectors much larger than your native vector length</p>



<a name="225128631"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225128631" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225128631">(Feb 04 2021 at 07:56)</a>:</h4>
<p>yeah, that's probably the best way to go about this if we're stuck writing out a bunch of implementations anyways. <span aria-label="weary" class="emoji emoji-1f629" role="img" title="weary">:weary:</span></p>



<a name="225128636"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225128636" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225128636">(Feb 04 2021 at 07:56)</a>:</h4>
<p>But it's not really typical I think</p>



<a name="225128640"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225128640" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225128640">(Feb 04 2021 at 07:56)</a>:</h4>
<p>Lol</p>



<a name="225128664"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225128664" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225128664">(Feb 04 2021 at 07:56)</a>:</h4>
<p>I agree it's not very typical so I'm not opposed to unifying T and U, at least, for now.</p>



<a name="225128953"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225128953" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225128953">(Feb 04 2021 at 08:00)</a>:</h4>
<p>at the end of the day I expect the major types that see the most use are going to be like<br>
{f, i, u}32x4 and u8x16</p>



<a name="225128986"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225128986" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225128986">(Feb 04 2021 at 08:01)</a>:</h4>
<p>agreed</p>



<a name="225129338"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225129338" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225129338">(Feb 04 2021 at 08:06)</a>:</h4>
<p>I push for flexibility mostly because, that said, I still don't know exactly what people are going to do, so I eagerly await the horrors that will be inflicted on this language, such as, say, seeing someone run the Rust compiler on a GPU or something. :P</p>
<p>after all, they can run Crysis <a href="https://www.tomshardware.com/news/gamer-installs-crysis-3-on-geforce-rtx-3090s-vram-and-it-runs">https://www.tomshardware.com/news/gamer-installs-crysis-3-on-geforce-rtx-3090s-vram-and-it-runs</a></p>



<a name="225129797"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225129797" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225129797">(Feb 04 2021 at 08:13)</a>:</h4>
<p>anyways, will sleep on it~ and hopefully review PRs between tomorrow~Sunday</p>



<a name="225131893"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225131893" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225131893">(Feb 04 2021 at 08:40)</a>:</h4>
<p><span class="user-mention silent" data-user-id="312331">Caleb Zulawski</span> <a href="#narrow/stream/257879-project-portable-simd/topic/Simd.20Shuffles/near/225128529">said</a>:</p>
<blockquote>
<p>Sorry, what I mean is does it make sense to take a 32 lane vector and make a 4 lane vector from it, etc</p>
</blockquote>
<p>That happens all the time in GPU shaders, even to the point that glsl has special syntax support for it: <code>v.xzw</code> means take lane 0, 2, and 3 and make a 3 lane vector. you can use any combination of x, y, z, and w. there are also aliases for rgba and for texture coordinates.</p>
<p>Also, shrinking shuffles are used in divide/conquer simd reduction algorithms.</p>



<a name="225162641"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225162641" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225162641">(Feb 04 2021 at 14:02)</a>:</h4>
<p>hmm.</p>



<a name="225172345"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225172345" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225172345">(Feb 04 2021 at 15:14)</a>:</h4>
<p>Is there a single architecture other than a GPU that supports shrinking shuffles though?</p>



<a name="225172399"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225172399" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225172399">(Feb 04 2021 at 15:14)</a>:</h4>
<p>My concern is if this is truly a portable operation</p>



<a name="225186260"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225186260" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225186260">(Feb 04 2021 at 16:40)</a>:</h4>
<p>how _does_ <code>shufflevector</code> get lowered from LLVM IR?</p>



<a name="225186997"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225186997" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225186997">(Feb 04 2021 at 16:44)</a>:</h4>
<p>I believe there is a special LLVM function for building shuffles (there isn't a particular representation in IR)</p>



<a name="225187090"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225187090" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225187090">(Feb 04 2021 at 16:45)</a>:</h4>
<p>Oh nevermind, I was wrong</p>



<a name="225187123"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225187123" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225187123">(Feb 04 2021 at 16:45)</a>:</h4>
<p>There is just an LLVM instruction</p>



<a name="225187186"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225187186" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225187186">(Feb 04 2021 at 16:45)</a>:</h4>
<p>Do you mean lowered from IR to asm?</p>



<a name="225187391"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225187391" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225187391">(Feb 04 2021 at 16:47)</a>:</h4>
<p>yes.</p>



<a name="225187441"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225187441" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225187441">(Feb 04 2021 at 16:47)</a>:</h4>
<p><a href="https://github.com/WebAssembly/simd/issues/8">https://github.com/WebAssembly/simd/issues/8</a> hm.</p>



<a name="225188005"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225188005" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225188005">(Feb 04 2021 at 16:51)</a>:</h4>
<p>Hm. I definitely agree with the conclusions that "general shuffles" are usually possible, though not always super efficient</p>



<a name="225188512"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225188512" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225188512">(Feb 04 2021 at 16:54)</a>:</h4>
<p>So wasm only has one vector length, so it doesn't provide shuffles that resize the vector</p>



<a name="225189177"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225189177" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225189177">(Feb 04 2021 at 16:59)</a>:</h4>
<p><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0214r0.pdf">http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0214r0.pdf</a> <span aria-label="pirate" class="emoji emoji-2620" role="img" title="pirate">:pirate:</span> <span aria-label="black flag" class="emoji emoji-1f3f4" role="img" title="black flag">:black_flag:</span> activating.</p>



<a name="225189262"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225189262" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225189262">(Feb 04 2021 at 17:00)</a>:</h4>
<p>Also, figure it's worth pointing out, if we went the constant argument route (like stdarch) rather than full const generics the API could both be stabilized sooner and wouldn't have the 64 lane limitation</p>



<a name="225189349"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225189349" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225189349">(Feb 04 2021 at 17:00)</a>:</h4>
<p>Using a const generic parameter is definitely more satisfying but there is precedent for doing it that way</p>



<a name="225189616"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225189616" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225189616">(Feb 04 2021 at 17:02)</a>:</h4>
<p>Hmm, that doc only refers to permutations and blends</p>



<a name="225189646"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225189646" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225189646">(Feb 04 2021 at 17:02)</a>:</h4>
<p>so<br>
the const argument thing? that was actually NEVER EVER meant to be exposed</p>



<a name="225189705"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225189705" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225189705">(Feb 04 2021 at 17:02)</a>:</h4>
<p>Lol</p>



<a name="225189769"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225189769" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225189769">(Feb 04 2021 at 17:03)</a>:</h4>
<p>That's reasonable</p>



<a name="225189844"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225189844" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225189844">(Feb 04 2021 at 17:03)</a>:</h4>
<p>I am stiffly against using that again to perpetuate that original mistake because it was a mistake, those exposed intrinsics should die in a fire, and there is a palpable argument they should have never ever been stabilized.</p>



<a name="225189997"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225189997" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225189997">(Feb 04 2021 at 17:04)</a>:</h4>
<p>and I should note that "oh, we did something that genuinely should never have been stabilized" is one of the few cases where the Rust teams are allowed to reconsider and back out, if it is demonstrated to be sufficiently unsound.</p>



<a name="225190028"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225190028" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225190028">(Feb 04 2021 at 17:05)</a>:</h4>
<p>That's fair, so we stick to const generics</p>



<a name="225191315"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225191315" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225191315">(Feb 04 2021 at 17:14)</a>:</h4>
<p>basically rustc_const_args was supposed to be for compiler-internal usage only, because... well, precisely because it doesn't have the same kind of rigorous const-qualification work behind it.</p>



<a name="225191601"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225191601" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225191601">(Feb 04 2021 at 17:16)</a>:</h4>
<p>That makes sense</p>



<a name="225191656"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225191656" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225191656">(Feb 04 2021 at 17:16)</a>:</h4>
<p>So my concern is that generics explicitly can't depend on other generics</p>



<a name="225191732"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225191732" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225191732">(Feb 04 2021 at 17:17)</a>:</h4>
<p>So we'd be limited to non-generic shuffles</p>



<a name="225191759"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225191759" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225191759">(Feb 04 2021 at 17:17)</a>:</h4>
<p>(generic size, I mean)</p>



<a name="225191830"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225191830" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225191830">(Feb 04 2021 at 17:17)</a>:</h4>
<p>It won't be possible to make a function "shuffle this vector into another vector of the same size" which is also the most common type of shuffle</p>



<a name="225192153"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225192153" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225192153">(Feb 04 2021 at 17:20)</a>:</h4>
<p>I think since actually we only need to depend on "one" thing, which is the input array, it's actually possible.</p>



<a name="225192202"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225192202" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225192202">(Feb 04 2021 at 17:20)</a>:</h4>
<p>though I suppose I should actually ask.</p>



<a name="225192267"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225192267" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225192267">(Feb 04 2021 at 17:21)</a>:</h4>
<p>Hmm</p>



<a name="225192846"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225192846" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225192846">(Feb 04 2021 at 17:25)</a>:</h4>
<p>lcnr <a href="#narrow/stream/260443-project-const-generics/topic/generic.20data.20dependency.20vs.2E.20arrays/near/225192727">said</a>:</p>
<blockquote>
<p>yeah, we're working on this under the <code>const_evaluatable_checked</code> feature gate</p>
</blockquote>
<p>so yes.</p>



<a name="225193083"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225193083" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225193083">(Feb 04 2021 at 17:27)</a>:</h4>
<p>...implementing shuffles as having the same array length right now and loosening it up later seems p. doable actually yeah.</p>



<a name="225202044"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225202044" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225202044">(Feb 04 2021 at 18:31)</a>:</h4>
<p><span class="user-mention silent" data-user-id="312331">Caleb Zulawski</span> <a href="#narrow/stream/257879-project-portable-simd/topic/Simd.20Shuffles/near/225172345">said</a>:</p>
<blockquote>
<p>Is there a single architecture other than a GPU that supports shrinking shuffles though?</p>
</blockquote>
<p>yes, x86 supports getting 64/128/256-bit vectors from 128/256/512-bit vectors</p>



<a name="225202175"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225202175" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225202175">(Feb 04 2021 at 18:32)</a>:</h4>
<p>also, SimpleV supports a very general shuffle instruction</p>



<a name="225203356"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225203356" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225203356">(Feb 04 2021 at 18:40)</a>:</h4>
<p>see <a href="https://gcc.godbolt.org/z/nn51x3">https://gcc.godbolt.org/z/nn51x3</a></p>



<a name="225203824"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225203824" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225203824">(Feb 04 2021 at 18:45)</a>:</h4>
<p><span class="user-mention" data-user-id="229517">@Jacob Lifshay</span> on x86 isn't that unrelated to shuffling though?</p>



<a name="225204047"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225204047" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225204047">(Feb 04 2021 at 18:47)</a>:</h4>
<p>Is there any instruction set that says ok take these 4 random elements of an 8 lane vector and produce a 4 lane vector</p>



<a name="225204131"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225204131" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225204131">(Feb 04 2021 at 18:47)</a>:</h4>
<p>Not to say we can't/shouldn't support that, but I do want to make sure that permuting a vector is ergonomic</p>



<a name="225204154"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225204154" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225204154">(Feb 04 2021 at 18:47)</a>:</h4>
<p>And should probably prioritize that, I think</p>



<a name="225204321"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225204321" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225204321">(Feb 04 2021 at 18:49)</a>:</h4>
<p>x86 has a pile of instructions for specific shuffles and a general instruction for 128-bit shuffles, but no general wider shuffle</p>



<a name="225204558"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225204558" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225204558">(Feb 04 2021 at 18:50)</a>:</h4>
<p>vextractf128 <em>is</em> a shuffle -- a specific one that picks either the low 128 bits or the high 128 bits for 256-bit vectors</p>



<a name="225204591"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225204591" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225204591">(Feb 04 2021 at 18:51)</a>:</h4>
<p><span class="user-mention" data-user-id="312331">@Caleb Zulawski</span> from an abstract consideration, "take 4 vectors of 128 bits with, say, f32x4s in them, and then construct an f32x4 from them" is in fact equivalent, and that's the NEON tbl instruction.</p>



<a name="225204777"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225204777" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225204777">(Feb 04 2021 at 18:52)</a>:</h4>
<p>because as opposed to taking f32x4 and f32x4 and extracting an f32x4 from between their elements, you're taking an "f32x8" and "f32x8" (REALLY you're taking an f32x4 and f32x4 and f32x4 and f32x4, but there's no <em>discernible difference</em>) and extracting an f32x4.</p>



<a name="225205568"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225205568" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225205568">(Feb 04 2021 at 18:58)</a>:</h4>
<p><span class="user-mention" data-user-id="229517">@Jacob Lifshay</span> fair, I suppose it's a very specific shuffle</p>



<a name="225205644"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225205644" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225205644">(Feb 04 2021 at 18:59)</a>:</h4>
<p>And can be combined with other shuffles and blends</p>



<a name="225205834"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225205834" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225205834">(Feb 04 2021 at 19:00)</a>:</h4>
<p>ok, after looking, x86 does have a fully generic shuffle, it was added in avx512</p>



<a name="225206126"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225206126" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225206126">(Feb 04 2021 at 19:02)</a>:</h4>
<p>Interesting. That's useful. AVX shuffles were always frustrating</p>



<a name="225208636"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225208636" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225208636">(Feb 04 2021 at 19:21)</a>:</h4>
<p>lol AVX512 tho'</p>



<a name="225208916"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225208916" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225208916">(Feb 04 2021 at 19:23)</a>:</h4>
<p><span class="user-mention" data-user-id="281757">@Jubilee</span> shall I suggest maybe the initial set of shuffles should be the type that aren't parameterized? Like interleaving, reversing, etc</p>



<a name="225208953"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225208953" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225208953">(Feb 04 2021 at 19:23)</a>:</h4>
<p>hm.</p>



<a name="225208989"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225208989" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225208989">(Feb 04 2021 at 19:23)</a>:</h4>
<p>And once supported by the compiler we move on to generic shuffles?</p>



<a name="225209299"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225209299" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225209299">(Feb 04 2021 at 19:25)</a>:</h4>
<p>so, after your idea of implementation based on size, I actually think we can have <code>v1.shuffle&lt;[w, x, y, z]&gt;(v2)</code> from day one and say that the semantics of <code>shuffle</code> are in fact "take two, make one of similar size", with later extension to indefinite length once const generics supports it.</p>



<a name="225209411"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225209411" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225209411">(Feb 04 2021 at 19:26)</a>:</h4>
<p>and also look at more-specific versions where it makes sense in our API overall?</p>



<a name="225209466"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225209466" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225209466">(Feb 04 2021 at 19:26)</a>:</h4>
<p>You think you can do that with the current state of const generics?</p>



<a name="225209521"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225209521" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225209521">(Feb 04 2021 at 19:27)</a>:</h4>
<p>I would like to try, at least.</p>



<a name="225209533"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225209533" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225209533">(Feb 04 2021 at 19:27)</a>:</h4>
<p>That API is definitely desirable I think</p>



<a name="225209578"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225209578" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225209578">(Feb 04 2021 at 19:27)</a>:</h4>
<p>I will be accepting similar limitations as our current version mind.</p>



<a name="225209675"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225209675" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225209675">(Feb 04 2021 at 19:28)</a>:</h4>
<p>Right, only implementing for specific sizes</p>



<a name="225209758"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225209758" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225209758">(Feb 04 2021 at 19:28)</a>:</h4>
<p>I assume you mean with <code>impl SimdU8&lt;16&gt;</code> etc?</p>



<a name="225209832"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225209832" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225209832">(Feb 04 2021 at 19:29)</a>:</h4>
<p>Rather than generic sizes</p>



<a name="225209928"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225209928" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225209928">(Feb 04 2021 at 19:29)</a>:</h4>
<p>yeah.</p>



<a name="225210079"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225210079" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225210079">(Feb 04 2021 at 19:30)</a>:</h4>
<p>I'm not 100% sure thats API compatible with the generic version but it seems to be</p>



<a name="225210261"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225210261" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225210261">(Feb 04 2021 at 19:31)</a>:</h4>
<p>The only reason it might not be is if we want to support resizing shuffles, the function is generic on array size too</p>



<a name="225210284"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225210284" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225210284">(Feb 04 2021 at 19:31)</a>:</h4>
<p>Otherwise sounds good though</p>



<a name="225211163"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225211163" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225211163">(Feb 04 2021 at 19:38)</a>:</h4>
<p>Right, I think we can add the const generic array parameter for array size later. This maaay preclude stabilization until we are sure this won't affect forward compat.</p>



<a name="225211222"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225211222" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225211222">(Feb 04 2021 at 19:38)</a>:</h4>
<p>but that's part of why I figured this would be a separately feature flagged API</p>



<a name="225211356"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225211356" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225211356">(Feb 04 2021 at 19:39)</a>:</h4>
<p>Works for me</p>



<a name="225211712"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225211712" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225211712">(Feb 04 2021 at 19:42)</a>:</h4>
<p>Something I'm also curious about is if dynamic shuffles const-propagate and produce static shuffles when possible</p>



<a name="225211739"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225211739" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225211739">(Feb 04 2021 at 19:42)</a>:</h4>
<p>Since that API is much simpler, I think</p>



<a name="225211755"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225211755" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225211755">(Feb 04 2021 at 19:42)</a>:</h4>
<p>May be possible to stabilize that first</p>



<a name="225212080"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225212080" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225212080">(Feb 04 2021 at 19:45)</a>:</h4>
<p>the answer is... maybe. And that's kind of why I am increasingly interested in just generating some forward motion, because compilation properties are something we'll mostly see after actual usage.</p>



<a name="225212453"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225212453" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225212453">(Feb 04 2021 at 19:48)</a>:</h4>
<p>Maybe a silly question, do the static and dynamic shuffles both just lower to <code>shufflevector</code>?</p>



<a name="225212732"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225212732" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225212732">(Feb 04 2021 at 19:50)</a>:</h4>
<p>I am... not sure! :D</p>



<a name="225212865"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225212865" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225212865">(Feb 04 2021 at 19:51)</a>:</h4>
<p>... if they do, perhaps we don't even <em>need</em> explicitly const shuffles?</p>



<a name="225212889"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225212889" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225212889">(Feb 04 2021 at 19:51)</a>:</h4>
<p>shufflevector specifies "shuffle mask vector constant, whose values are const integers or undef"</p>



<a name="225212890"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225212890" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225212890">(Feb 04 2021 at 19:51)</a>:</h4>
<p><span class="user-mention silent" data-user-id="312331">Caleb Zulawski</span> <a href="#narrow/stream/257879-project-portable-simd/topic/Simd.20Shuffles/near/225211739">said</a>:</p>
<blockquote>
<p>Since that API is much simpler, I think</p>
</blockquote>
<p>Strong, strong <span aria-label="thumbs down" class="emoji emoji-1f44e" role="img" title="thumbs down">:thumbs_down:</span> as a user here. The API for constant shuffles guaranteeing that they are constant is a feature worth keeping.</p>



<a name="225213015"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225213015" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225213015">(Feb 04 2021 at 19:52)</a>:</h4>
<p>Sorry, when I said simpler I meant in terms of const generics</p>



<a name="225213036"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225213036" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225213036">(Feb 04 2021 at 19:52)</a>:</h4>
<p>As in, can be written with rustc today</p>



<a name="225213120"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225213120" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225213120">(Feb 04 2021 at 19:53)</a>:</h4>
<p>also cranelift can wind up having different lowering. <del>supposedly some people are already using cranelift for narrow compilation cases because it's better in terms of loop optimization?</del> no I just misunderstood something, lol.</p>



<a name="225213866"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225213866" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225213866">(Feb 04 2021 at 19:58)</a>:</h4>
<p>Yeah, I just mean that having a single api for dynamic shuffles that only generates constant shuffles if const prop to kicks in is bad. Even if it is very reliable, this would be unfortunate and will almost certainly bite people who will be surprised that e.g. rustc didn't const eval shuffle returned <code>const fn</code> argument</p>



<a name="225213993"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225213993" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225213993">(Feb 04 2021 at 19:59)</a>:</h4>
<p>yeah, people already misunderstand that const fn is not actually itself sufficient to create a const context a LOT</p>



<a name="225214533"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225214533" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225214533">(Feb 04 2021 at 20:02)</a>:</h4>
<p>yeah. even if somehow this function had some hint that "really try to const eval the argument"... in the <em>best</em> case it would people would need to  periodically verify assembly... also concerns like bounds checking and stuff could crop up.</p>
<p>i honestly would wonder if the dynamic shuffle and more general permutation stuff belong together more than const/dynamic shuffle, if we're talkign about api structure... not certain about that ofc</p>



<a name="225214623"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225214623" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225214623">(Feb 04 2021 at 20:03)</a>:</h4>
<p>i think encoding stuff often uses dynamic shuffles (and more powerful permutations as well), so perhaps <span class="user-mention" data-user-id="314350">@Henri Sivonen</span> has some insight there.</p>



<a name="225216718"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225216718" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225216718">(Feb 04 2021 at 20:18)</a>:</h4>
<p>I suppose my general point is that dynamic shuffles and non-parameterized shuffles are fairly trivial to implement and can definitely be implemented in an API-stable way, so we can potentially stabilize those while the others are still in flux</p>



<a name="225216753"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225216753" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225216753">(Feb 04 2021 at 20:19)</a>:</h4>
<p>Anything else was just musings <span aria-label="grinning face with smiling eyes" class="emoji emoji-1f601" role="img" title="grinning face with smiling eyes">:grinning_face_with_smiling_eyes:</span></p>



<a name="225217111"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225217111" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225217111">(Feb 04 2021 at 20:22)</a>:</h4>
<p>I think having just interleaving etc will be sufficient for most people, you can always convert to the std::arch type if necessary, and getting the fully generic interface will be the icing on the cake</p>



<a name="225217707"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225217707" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225217707">(Feb 04 2021 at 20:27)</a>:</h4>
<p>also apparently the paper I posted earlier got updated since then and is on <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0214r9.pdf">http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0214r9.pdf</a><br>
and here's the primary author's blog I guess? <a href="https://mattkretz.github.io/">https://mattkretz.github.io/</a> nice.</p>



<a name="225220118"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225220118" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225220118">(Feb 04 2021 at 20:48)</a>:</h4>
<p><span class="user-mention" data-user-id="281757">@Jubilee</span> you posted about const generics shuffles that it'd be v1.shuffle(v2) where v2 could have a different length. Are there functions like that which can shuffle two different sized vectors together? I've always seen shuffles with both sides being the same length.</p>



<a name="225220506"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225220506" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225220506">(Feb 04 2021 at 20:50)</a>:</h4>
<p><span class="user-mention" data-user-id="224471">@Lokathor</span> oh no, no, I didn't mean to say that if I did! what I meant that for anything using <code>fn simd_shuffle{N}</code>, the signature required by rustc is effectively <code>shuffle&lt;IDX&gt;(T, T) -&gt; U</code></p>



<a name="225220598"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225220598" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225220598">(Feb 04 2021 at 20:51)</a>:</h4>
<p>your example in the const eval thread had an additional input length on the shuffle separate from the &amp;self length</p>



<a name="225220710"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225220710" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225220710">(Feb 04 2021 at 20:52)</a>:</h4>
<p>const S only affects U, not T, and is actually part of the parameterization of M.</p>



<a name="225220797"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225220797" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225220797">(Feb 04 2021 at 20:53)</a>:</h4>
<p>( M for mask because that's what the shufflevector input is called, S arbitrarily for Size because I didn't want to use LEN and L in the same example for some reason )</p>



<a name="225229908"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225229908" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225229908">(Feb 04 2021 at 22:00)</a>:</h4>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">use</span><span class="w"> </span><span class="k">crate</span>::<span class="n">SimdU32</span><span class="p">;</span><span class="w"></span>

<span class="fm">macro_rules!</span><span class="w"> </span><span class="n">impl_shuffle_lane</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="p">{</span><span class="w"> </span><span class="cp">$t</span>:<span class="nc">ident</span><span class="p">,</span><span class="w"> </span><span class="cp">$fn</span>:<span class="nc">ident</span><span class="p">,</span><span class="w"> </span><span class="cp">$n</span>:<span class="nc">literal</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="k">impl</span><span class="w"> </span><span class="cp">$t</span><span class="o">&lt;</span><span class="cp">$n</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">            </span><span class="k">pub</span><span class="w"> </span><span class="k">fn</span> <span class="nf">shuffle</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">M</span>: <span class="p">[</span><span class="kt">u32</span><span class="p">;</span><span class="w"> </span><span class="cp">$n</span><span class="p">]</span><span class="o">&gt;</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">other</span>: <span class="nc">Self</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">Self</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">                </span><span class="kd">let</span><span class="w"> </span><span class="n">f</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">crate</span>::<span class="n">intrinsics</span>::<span class="cp">$fn</span><span class="p">;</span><span class="w"></span>
<span class="w">                </span><span class="k">unsafe</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">f</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">other</span><span class="p">,</span><span class="w"> </span><span class="n">M</span><span class="p">)</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="w">            </span><span class="p">}</span><span class="w"></span>
<span class="w">        </span><span class="p">}</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="n">expand_shuffle</span><span class="o">!</span><span class="p">{</span><span class="w"> </span><span class="n">SimdU32</span><span class="p">,</span><span class="w"> </span><span class="n">simd_shuffle4</span><span class="p">,</span><span class="w"> </span><span class="mi">4</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>aaand we're in business! ^_^</p>



<a name="225236047"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225236047" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225236047">(Feb 04 2021 at 22:51)</a>:</h4>
<p>Okay~!</p>



<a name="225236060"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225236060" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225236060">(Feb 04 2021 at 22:51)</a>:</h4>
<p>PR open this time.</p>



<a name="225593204"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Simd%20Shuffles/near/225593204" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Simd.20Shuffles.html#225593204">(Feb 08 2021 at 19:14)</a>:</h4>
<blockquote>
<p>I was about to ask about the "reverse" (trait bounds depending on const parameters), I see that this already works, even by mentioning a const param that's declared after (tested that because of the ordering restriction on stable):</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">trait</span><span class="w"> </span><span class="n">X</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">usize</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="k">fn</span> <span class="nf">foo</span><span class="o">&lt;</span><span class="n">T</span>: <span class="nc">X</span><span class="o">&lt;</span><span class="n">N</span><span class="o">&gt;</span><span class="p">,</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">usize</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
</code></pre></div>
<p>Is it intentional that that compiles?</p>
</blockquote>
<p>someone brought this up in const parameter pull @ <a href="https://github.com/rust-lang/project-const-generics/pull/3">https://github.com/rust-lang/project-const-generics/pull/3</a> as an example of code that <em>does</em> compile. Interesting.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>